// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.commands.serverCommands;

import java.util.TreeMap;
import java.util.Map.Entry;
import zombie.commands.CommandArgs;
import zombie.commands.CommandBase;
import zombie.commands.CommandHelp;
import zombie.commands.CommandName;
import zombie.commands.RequiredRight;
import zombie.core.raknet.UdpConnection;
import zombie.network.GameServer;
import zombie.network.ServerOptions;

@CommandName(
    name = "help"
)
@CommandArgs(
    optional = "(\\w+)"
)
@CommandHelp(
    helpText = "UI_ServerOptionDesc_Help"
)
@RequiredRight(
    requiredRights = 32
)
public class HelpCommand extends CommandBase {
    public HelpCommand(String username, String userAccessLevel, String command, UdpConnection connection) {
        super(username, userAccessLevel, command, connection);
    }

    @Override
    protected String Command() {
        String string0 = this.getCommandArg(Integer.valueOf(0));
        if (string0 != null) {
            Class class0 = findCommandCls(string0);
            return class0 != null ? getHelp(class0) : "Unknown command /" + string0;
        } else {
            String string1 = " <LINE> ";
            StringBuilder stringBuilder = new StringBuilder();
            if (this.connection == null) {
                string1 = "\n";
            }

            if (!GameServer.bServer) {
                for (String string2 : ServerOptions.getClientCommandList(this.connection != null)) {
                    stringBuilder.append(string2);
                }
            }

            stringBuilder.append("List of ").append("server").append(" commands : ");
            String string3 = "";
            TreeMap treeMap = new TreeMap();

            for (Class class1 : getSubClasses()) {
                if (!isDisabled(class1)) {
                    string3 = getHelp(class1);
                    if (string3 != null) {
                        treeMap.put(getCommandName(class1), string3);
                    }
                }
            }

            for (Entry entry : treeMap.entrySet()) {
                stringBuilder.append(string1).append("* ").append((String)entry.getKey()).append(" : ").append((String)entry.getValue());
            }

            return stringBuilder.toString();
        }
    }
}
